// Set去重
(() => {
  let data = new Set([1, 3, 3, 2]);
  console.log('Set去重', [...data]);
})();

// 两层for循环
(() => {
  let arr = [1, 3, 3, 2];
  let result = [];
  for (let i = 0; i < arr.length; i++) {
    let flag = true;
    for (let j = i + 1; j < arr.length; j++) {
      if (arr[i] === arr[j]) {
        flag = false;
      }
    }
    if (flag) {
      result.push(arr[i]);
    }
  }
  console.log('两层for循环', result);
})();

// indexOf实现
(() => {
  let arr = [1, 3, 2, 2];
  var result = [];
  for (let i = 0; i < arr.length; i++) {
    // if (result.indexOf(arr[i]) === -1) {
    //   result.push(arr[i]);
    // }
    if (!result.includes(arr[i])) {
      result.push(arr[i]);
    }
  }
  console.log('indexOf实现', result);
})();

// filter实现
(() => {
  let arr = [1, 3, 2, 2];
  let arr__ = arr.filter((item, index) => {
    return arr.indexOf(item) === index;
  });
  console.log('filter实现', arr__);
})();

